package willand.com.cloud.clickhouse.clickhousejdbc.factory;

import com.clickhouse.jdbc.DataSourceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;
import java.util.Properties;

@Configuration
public class ClickhouseBeanFactory {

    @Bean
    public DataSource dataSource(){
        String url = "jdbc:clickhouse://10.139.0.39:9123/willand_cloud";
        Properties info = new Properties();
        info.put("user", "willand_cloud");
        info.put("password", "willand_CLOUD_!@#$");
        DataSource dataSource = new DataSourceImpl(url, info);
        return dataSource;
    }

    @Bean
    public JdbcTemplate jdbcTemplate(DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }


}

